package edu.cmpe283.prj2.controller;

import edu.cmpe283.prj2.manager.VmManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;



@Controller
public class ChartController {


    @Qualifier("vmManager")
    @Autowired
    private VmManager vmManager;

    @RequestMapping(value = "vm/cpu", method = RequestMethod.GET)
    public String getChart(ModelMap model) {



        model.addAttribute("axis", vmManager.getVmCpu());
        
       
        return "vmCpu";
    }
    
    @RequestMapping(value = "/vm/memory", method = RequestMethod.GET)
    public String getMemoryChart(ModelMap model) {



        model.addAttribute("axis",  vmManager.getVmMemoryData());
        
      
        return "vmMemory";
    }
    
    
    @RequestMapping(value = "/vm/diskRead", method = RequestMethod.GET)
    public String getDiskChartRead(ModelMap model) {



        model.addAttribute("axis",  vmManager.getVmDiskDataRead());
        
      
        return "vmDisk";
    }
    
    @RequestMapping(value = "/vm/diskWrite", method = RequestMethod.GET)
    public String getDiskChartWrite(ModelMap model) {



        model.addAttribute("axis",  vmManager.getVmDiskDataRead());
        
      
        return "vmDisk";
    }
    
    @RequestMapping(value = "/vm/networkTX", method = RequestMethod.GET)
    public String getNetworkChart(ModelMap model) {



        model.addAttribute("axis",  vmManager.getVmNetworkTx());
        
      
        return "vmNetwork";
    }
    
    
    
    
    
    
    @RequestMapping(value = "/vm/networkRx", method = RequestMethod.GET)
    public String getNetworkRxChart(ModelMap model) {



        model.addAttribute("axis",  vmManager.getVmNetworkRx());
        
      
        return "vmNetworkRx";
    }
    
    
    
    
    @RequestMapping(value = "/vm/processThreads", method = RequestMethod.GET)
    public String getProcessChart(ModelMap model) {



        model.addAttribute("axis",  vmManager.getVmProcessThreads());
        
      
        return "vmProcessThreads";
    }
    
    @RequestMapping(value = "/host/CPU", method = RequestMethod.GET)
    public String getHostCpu(ModelMap model) {

        model.addAttribute("axis",  vmManager.getHostCPU());
        
      
        return "hostCpu";
    }
    
    @RequestMapping(value = "/host/Mem", method = RequestMethod.GET)
    public String getHostMem(ModelMap model) {

        model.addAttribute("axis",  vmManager.getHostMem());
        
      
        return "hostMem";
    }
    
    @RequestMapping(value = "/host/NetworkTx", method = RequestMethod.GET)
    public String getHostNetworkTx(ModelMap model) {

        model.addAttribute("axis",  vmManager.getHostNetworkTx());
        
      
        return "hostNetworkTx";
    }
    
    @RequestMapping(value = "/host/NetworkRx", method = RequestMethod.GET)
    public String getHostNetworkRx(ModelMap model) {

        model.addAttribute("axis",  vmManager.getHostNetworkRx());
        
      
        return "hostNetworkRx";
    }
    
}
